var OneDay = 24 * 3600 * 1000;
require('date-utils');
module.exports = {

  addDays: function(date, days) {
    return new Date(date.getTime() + OneDay * days);
  },

  generateOrderNum: function() {
    var time = new Date().toFormat('YYMMDDHH24MISS');
    time = time.substr(1);
    return "D" + time + this._randomThreeNum();
  },

  generateBillNum: function() {
    var time = new Date().toFormat('YYMMDDHH24MISS');
    time = time.substr(1);
    return "B" + time + this._randomThreeNum();
  },

  _randomThreeNum: function () {
    var num = Math.floor(Math.random() * 1000);
    if(num < 100) {
      return '0' + num;
    }
    if(num < 10) {
      return '00' + num;
    }
    return num;
  }
}

//console.log(module.exports.generateOrderNum())
